#ifndef _VOXEL_COLLISION_DETECTOR
#define _VOXEL_COLLISION_DETECTOR

#include "stdafx.h"


class DecoScene;
class DecoSceneObject;
class DecoRenderInterface;
class DecoLight;

enum CollisionType
{
	CT_Self,
	CT_Mutual
};

class CollidingVoxel
{
public:
	Index3 mId;
	vector3 mPos;
	double mGridSize;
	CollisionType mCollisionType;
	DecoSceneObject* mObj1;
	DecoSceneObject* mObj2;
	int mBody1;
	int mBody2;
	CollidingVoxel(	const Index3& id, const vector3& pos, double gridSize);
};

class VoxelCollisionDetector
{
public:
	VoxelCollisionDetector();
	~VoxelCollisionDetector();
	void SetScene(DecoScene* scene);
	double CollisionDetection();
	void Render(DecoRenderInterface* RI, DecoLight** Lights, UINT numEffectiveLights);
	//	double GetOverlapVolume();
	//	void GetAllCollisionInfo(std::vector<CollidingVoxel>& collisionInfo);
private:
	int mXRes;
	int mYRes;
	int mZRes;
	double mXStep;
	double mYStep;
	double mZStep;
	DecoScene* mScene;
	std::vector<CollidingVoxel> mCollidingVoxels;
	std::vector<Index3> mCollidingVoxelsForVis;
	BYTE*** mVoxelGrid;
	double collisionDetectionForBodies(int* bodyArray1, int* bodyArray2, int numArray1, int numArray2);
};

#endif